package com.ays.comm;

import cn.hutool.json.JSONObject;
import cn.hutool.json.XML;
import lombok.extern.slf4j.Slf4j;

import java.util.Date;

/**
 * @author Administrator
 * @date 2024/6/7
 * @desc
 */
@Slf4j
public class ResponseUtil {
    public static String getXml(String data){
        JSONObject result = new JSONObject();
        JSONObject header = new JSONObject();
        header.putOnce("SourceSystem","anes");
        header.putOnce("MessageID",new Date().getTime());
        result.putOnce("Header",header);
        JSONObject body = new JSONObject();
        if("ok".equals(data)){
            body.putOnce("ResultCode","0");
            body.putOnce("ResultContent","成功");
            JSONObject successIDList = new JSONObject();
            successIDList.putOnce("RowID",data);
//            body.putOnce("SuccessIDList",successIDList);
        }else {
            body.putOnce("ResultCode","-1");
            body.putOnce("ResultContent","失败：" + data);
        }
        result.putOnce("Body",body);
        String xml = XML.toXml(result);
        log.debug(xml);
        return xml;
    }
    
}
